local ModifyPwdLayer = {}

ModifyPwdLayer.m_PanelModifyPwd = nil
 
function ModifyPwdLayer.show( widget )
    print("============ModifyPwdLayer.show===============")
    ModifyPwdLayer:init(widget)
end

function ModifyPwdLayer:closeWindow() 
    self.m_PanelModifyPwd:setLocalZOrder(-1)
    self.m_PanelModifyPwd:setVisible(false)
end


function ModifyPwdLayer:init( widget )
    
    print("============ModifyPwdLayer:init============")
    self.m_PanelModifyPwd = ccui.Helper:seekWidgetByName(widget.m_Json,"PanelModifyPwd")
    local WinSize = cc.Director:getInstance():getWinSize()
    local CurSize = self.m_PanelModifyPwd:getContentSize()
    self.m_PanelModifyPwd:setPositionX(15)
    self.m_PanelModifyPwd:setPositionY(WinSize.height/4) 
    self.m_PanelModifyPwd:setVisible(true)
    self.m_PanelModifyPwd:setLocalZOrder(5)
 
     
    self.m_TextFieldOldPassword = ccui.Helper:seekWidgetByName(self.m_PanelModifyPwd,"TextFieldOldPassword")
    self.m_TextFieldOldPassword:setPlaceHolder(LocalizedString("login_password_tips"))
    self.m_TextFieldOldPassword:setFontName(DEFAULT_FONT)
    self.m_TextFieldOldPassword:setFontSize(18)
    self.m_TextFieldOldPassword:setPasswordEnabled(true)
    self.m_TextFieldOldPassword:setPasswordStyleText("*")
    self.m_TextFieldOldPassword:setMaxLengthEnabled(true)
    self.m_TextFieldOldPassword:setMaxLength(6)
    self.m_TextFieldOldPassword:addEventListener(handler(self, self.textFieldEvent))
    self.m_TextFieldOldPassword:setText("")
    
    self.m_TextFieldPassword = ccui.Helper:seekWidgetByName(self.m_PanelModifyPwd,"TextFieldPassword")
    self.m_TextFieldPassword:setPlaceHolder(LocalizedString("login_password_tips"))
    self.m_TextFieldPassword:setFontName(DEFAULT_FONT)
    self.m_TextFieldPassword:setFontSize(18)
    self.m_TextFieldPassword:setPasswordEnabled(true)
    self.m_TextFieldPassword:setPasswordStyleText("*")
    self.m_TextFieldPassword:setMaxLengthEnabled(true)
    self.m_TextFieldPassword:setMaxLength(6)
    self.m_TextFieldPassword:addEventListener(handler(self, self.textFieldEvent))
    self.m_TextFieldPassword:setText("")
    
    self.m_TextFieldRePassword = ccui.Helper:seekWidgetByName(self.m_PanelModifyPwd,"TextFieldRePassword")
    self.m_TextFieldRePassword:setPlaceHolder(LocalizedString("login_password_tips"))
    self.m_TextFieldRePassword:setFontName(DEFAULT_FONT)
    self.m_TextFieldRePassword:setFontSize(18)
    self.m_TextFieldRePassword:setPasswordEnabled(true)
    self.m_TextFieldRePassword:setPasswordStyleText("*")
    self.m_TextFieldRePassword:setMaxLengthEnabled(true)
    self.m_TextFieldRePassword:setMaxLength(6)
    self.m_TextFieldRePassword:addEventListener(handler(self, self.textFieldEvent))
    self.m_TextFieldRePassword:setText("")
    
    self.m_BtnOk = ccui.Helper:seekWidgetByName(self.m_PanelModifyPwd,"BtnOk")
    self.m_BtnOk:setTouchEnabled(true)
    self.m_BtnOk:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
 
    self.m_BtnCancel = ccui.Helper:seekWidgetByName(self.m_PanelModifyPwd,"BtnCancel")
    self.m_BtnCancel:setTouchEnabled(true)
    self.m_BtnCancel:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end) 

  
end

function ModifyPwdLayer:textFieldEvent(sender, eventType)
    if eventType == ccui.TextFiledEventType.attach_with_ime then

    elseif eventType == ccui.TextFiledEventType.detach_with_ime then

    elseif eventType == ccui.TextFiledEventType.insert_text then

    elseif eventType == ccui.TextFiledEventType.delete_backward then

    end
end

function ModifyPwdLayer:onMenutClick(sender,eventType)
    if eventType == ccui.TouchEventType.ended then
        if sender == self.m_BtnOk then     
            print "=========ModifyPwdLayer:onMenutClick m_BtnOk======================="
        elseif sender == self.m_BtnCancel then     
            print "=========ModifyPwdLayer:onMenutClick m_BtnBack======================="
            self:closeWindow()
        end
    end
end
 
return ModifyPwdLayer